package com.zelma.agent.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zelma.common.utils.PageUtils;
import com.zelma.common.utils.Query;

import com.zelma.agent.dao.AgentDao;
import com.zelma.agent.entity.AgentEntity;
import com.zelma.agent.service.AgentService;


@Service("agentService")
public class AgentServiceImpl extends ServiceImpl<AgentDao, AgentEntity> implements AgentService {


    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<AgentEntity> wrapper = new QueryWrapper<>();
        String agentName = (String) params.get("agentName");
        if (agentName != null){
            wrapper.like("agent_name",agentName);
        }
        if (agentName != null){
            wrapper.like("agent_phone",agentName);
        }
        String agentStatus = (String) params.get("agentStatus");
        if (agentStatus != null){
            wrapper.like("agent_status",agentStatus);
        }
        IPage<AgentEntity> page = this.page(
                new Query<AgentEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

    @Override
    public void RankingByName(String agentName) {
        baseMapper.RankingByName(agentName);
    }
}